package com.mv.controller;

import com.mv.pojo.Admin;
import com.mv.service.AdminService;
import com.mv.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/mv")
public class AdminController {

    @Autowired
    private AdminService adminService;
    /*管理员注册*/
    @PostMapping("/admin/logon")
    public SysResult logon(@RequestBody Admin admin){
        Boolean flag=adminService.logon(admin);
        if(flag==false){
            return SysResult.fail();
        }
        return SysResult.success();
    }
    /*管理员登录*/
    @PostMapping("/admin/login")
    public SysResult login(@RequestBody Admin admin){
        /*返回一个字符串token*/
        Admin adminDB= adminService.login(admin);
        if(adminDB == null){
            return SysResult.fail();
        }
        return SysResult.success(adminDB);
    }
}
